home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / BLKIO_.H < prev    next >
Text File  |  1991-09-23  |  4KB  |  122 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /*man---------------------------------------------------------------------------
  5. NAME
  6.      blkio_.h - private header for blkio library
  7.  
  8. SYNOPSIS
  9.      #include "blkio_.h"
  10.  
  11. DESCRIPTION
  12.      This is a private header file included by the blkio library
  13.      modules.
  14.  
  15. ------------------------------------------------------------------------------*/
  16. #ifndef H_BLKIO_    /* prevent multiple includes */
  17. #define H_BLKIO_
  18.  
  19. /* #ident    "@(#)blkio_.h    1.5 - 91/09/23" */
  20.  
  21. #include <ansi.h>
  22.  
  23. /*#define DEBUG        /* switch to enable debugging for blkio library */
  24.  
  25. /* The OPSYS macro specifies the operating system.  Currently supported       */
  26. /* systems are:                                                               */
  27. #define OS_AMIGADOS    (1)        /* Amiga DOS - not yet implemented */
  28. #define OS_DOS        (2)        /* DOS */
  29. #define OS_MAC        (3)        /* Macintosh - not yet implemented */
  30. #define OS_UNIX        (4)        /* UNIX */
  31. #define OS_VMS        (5)        /* VMS - not yet implemented */
  32. #define OPSYS        OS_DOS
  33.  
  34. /* The CCOM macro specifies the C compiler being used.  Currently supported   */
  35. /* compilers are:                                                             */
  36. #define CC_UNIX        (1)        /* UNIX C compiler */
  37. #define CC_BC        (2)        /* Borland Turbo C or C++ */
  38. #define CC_MSC        (3)        /* Microsoft C */
  39. #define CC_MSQC        (4)        /* Microsoft Quick C */
  40. #define CCOM        CC_BC
  41.  
  42. /*#define SINGLE_USER    /* switch to disable file locking system calls */
  43.  
  44. /* non-ansi headers */
  45. #include <bool.h>
  46.  
  47. /* local headers */
  48. #include "blkio.h"
  49.  
  50. /* tables */
  51. extern BLKFILE biob[BOPEN_MAX];    /* BLKFILE control struct table declaration */
  52.  
  53. /* BLKFILE bit flags */
  54. #define BIOOPEN          (03)    /* open status bits */
  55. #define BIOREAD          (01)    /* block file is open for reading */
  56. #define BIOWRITE      (02)    /* block file is open for writing */
  57. #define BIOUSRBUF      (04)    /* user supplied buffer */
  58. #define BIOERR        (0100)    /* error has occurred on this block file */
  59.  
  60. /* block_t bit flags */
  61. #define BLKREAD          (01)    /* block can be read */
  62. #define BLKWRITE      (02)    /* block needs to be written to disk */
  63. #define BLKERR        (0100)    /* error has occurred on this block */
  64.  
  65. /* function declarations */
  66. #ifdef AC_PROTO
  67. int    b_alloc(BLKFILE *bp);
  68. void    b_free(BLKFILE *bp);
  69. int    b_get(BLKFILE *bp, size_t i);
  70. int    b_initlist(BLKFILE *bp);
  71. int    b_mkmru(BLKFILE *bp, size_t i);
  72. int    b_put(BLKFILE *bp, size_t i);
  73. bool    b_valid(const BLKFILE *bp);
  74.  
  75. int    b_uclose(BLKFILE *bp);
  76. int    b_uendblk(BLKFILE *bp, bpos_t *endblkp);
  77. int    b_ugetf(BLKFILE *bp, bpos_t bn, size_t offset, void *buf, size_t bufsize);
  78. int    b_uopen(BLKFILE *bp, const char *filename, const char *type);
  79. int    b_uputf(BLKFILE *bp, bpos_t bn, size_t offset, const void *buf, size_t bufsize);
  80. #else
  81. int    b_alloc();
  82. void    b_free();
  83. int    b_get();
  84. int    b_initlist();
  85. int    b_mkmru();
  86. int    b_put();
  87. bool    b_valid();
  88.  
  89. int    b_uclose();
  90. int    b_uendblk();
  91. int    b_ugetf();
  92. int    b_uopen();
  93. int    b_uputf();
  94. #endif    /* #ifdef AC_PROTO */
  95.  
  96. /* macros */
  97. #define    b_blkbuf(BP, N) ((void *)(                    \
  98.         (char *)(BP)->blkbuf +                    \
  99.         ((N) == 0 ? 0 : (BP)->hdrsize + ((N) - 1) * (BP)->blksize)\
  100. ))
  101. #define    b_blockp(BP, N) ((block_t *)(                    \
  102.         (char *)(BP)->blockp +    (N) * sizeof(block_t)        \
  103. ))
  104.  
  105. /* block file open types */
  106. #define BF_READ        ("r")
  107. #define BF_RDWR        ("r+")
  108. #define BF_CRTR        ("w+")
  109. #define BF_CREATE    ("c")
  110.  
  111. #ifdef DEBUG
  112. #include <stdio.h>
  113. #define    BEPRINT {                            \
  114.     fprintf(stderr, "*** blkio error line %d of %s. errno = %d.\n",    \
  115.         __LINE__, __FILE__, errno);                \
  116. }
  117. #else
  118. #define BEPRINT
  119. #endif
  120.  
  121. #endif    /* #ifndef H_BLKIO_ */
  122.